




using System;
using System.Data;using THSERP.BusinessEntities;using THSERP.BaseProvider;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using THSLib;using THSERP.BaseProvider;

namespace THSERP.Modules.Supplier
{
    public class SupplierEntities : ERPModuleEntities
    {
        #region Declare Constant
        public readonly static String strAPSuppliersObjectName = "APSuppliers";

        public readonly static String strAPSupplierContactsObjectName = "APSupplierContacts";
        #endregion

        #region Declare all entities variables
        private APSuppliersInfo _aRSuppliersObject;
        private APSupplierContactsInfo _aRSupplierContactsObject;

        public THSList<APSupplierContactsInfo> lstAPSupplierContacts;
        public THSList<ICProductsInfo> lstICProducts;
        #endregion

        #region Public Properties
        public APSuppliersInfo APSuppliersObject
        {
            get
            {
                return _aRSuppliersObject;
            }
            set
            {
                _aRSuppliersObject = value;
            }
        }
        public APSupplierContactsInfo aRSupplierContactsObject
        {
            get
            {
                return _aRSupplierContactsObject;
            }
            set
            {
                _aRSupplierContactsObject = value;
            }
        }

        public THSList<APSupplierContactsInfo> APSupplierContactsList
        {
            get
            {
                return lstAPSupplierContacts;
            }
            set
            {
                lstAPSupplierContacts = value;
            }
        }

        public THSList<ICProductsInfo> ICProductsList
        {
            get
            {
                return lstICProducts;
            }
            set
            {
                lstICProducts = value;
            }
        }
        #endregion

        #region Constructor
        public SupplierEntities()
            : base()
        {
            _aRSuppliersObject = new APSuppliersInfo();

            _aRSupplierContactsObject = new APSupplierContactsInfo();

            lstAPSupplierContacts = new THSList<APSupplierContactsInfo>();
            lstICProducts = new THSList<ICProductsInfo>();
        }

        #endregion

        #region Init Main Object,Module Objects functions
        public override void InitMainObject()
        {

            MainObject = APSuppliersObject;
        }

        public override void InitModuleObjects()
        {
            ModuleObjects.Add("APSupplierContacts", aRSupplierContactsObject);
        }

        public override void InitModuleObjectList()
        {
            lstAPSupplierContacts = new THSList<APSupplierContactsInfo>();
            //lstAPSupplierContacts.InitTHSList(this, THSUtil.GetTableNameFromBusinessObjectType(typeof(APSupplierContactsInfo)));
            lstAPSupplierContacts.InitTHSList(this, "APSuppliers", "APSupplierContacts");
            lstICProducts = new THSList<ICProductsInfo>();
            lstICProducts.InitTHSList(this, String.Empty, "ICProducts");
        }

        public override void InitGridControlInTHSList()
        {
            lstAPSupplierContacts.InitTHSListGridControl();
            lstICProducts.InitTHSListGridControl("fld_dgcICProducts");
        }

        public override void SetDefaultModuleObjectsList()
        {
            try
            {
                lstAPSupplierContacts.SetDefaultListAndRefreshGridControl();
                lstICProducts.SetDefaultListAndRefreshGridControl();

            }
            catch (Exception)
            {
                return;
            }
        }

        #endregion

        #region Invalidate Module Objects functions


        public override void InvalidateModuleObjects(int iObjectID)
        {
            APSupplierContactsList.Invalidate(iObjectID);
        }


        #endregion

        #region Save Module Objects functions

        public override void SaveModuleObjects()
        {
            APSupplierContactsList.SaveItemObjects(true);
        }

        #endregion


    }
}
